package com.srcbox.file.fragment.pager

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.fastjson.JSON
import com.srcbox.file.R
import com.srcbox.file.adapter.FunList
import com.srcbox.file.util.EggIO

class MainB() : Fragment() {
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val v = inflater.inflate(R.layout.main_nav_two, container, false)
        initView(v)
        return v
    }

    private fun initView(v: View) {
        val funList = v.findViewById<RecyclerView>(R.id.funList)
        val appFunAdapter =
            FunList(
                context!!,
                JSON.parseArray(EggIO().readFile(context!!.assets.open("funList.json")))
            )
        funList.layoutManager = GridLayoutManager(context, 3)
        funList.adapter = appFunAdapter
    }
}